package com.yonyou.sto.modules.ums.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yonyou.sto.common.api.CommonPage;
import com.yonyou.sto.common.api.CommonResult;
import com.yonyou.sto.modules.ims.dto.ImsPartySelectParam;
import com.yonyou.sto.modules.ims.model.ImsParty;
import com.yonyou.sto.modules.ums.model.UmsNcOrg;
import com.yonyou.sto.modules.ums.service.UmsNcOrgService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/server/ums/umsNcOrg")
public class UmsNcOrgController {

    @Autowired
    private UmsNcOrgService umsNcOrgService;

    @ApiOperation(value = "根据组织编码名称分页查询组织")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public CommonResult<CommonPage<UmsNcOrg>> list(@RequestParam(value = "keyword", required = false) String keyword,
                                                   @RequestParam(value = "pageSize", defaultValue = "100") Integer pageSize,
                                                   @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
        Page<UmsNcOrg> partyPage = umsNcOrgService.list(keyword, pageSize, pageNum);
        return CommonResult.success(CommonPage.restPage(partyPage));
    }

    @ApiOperation(value = "获取组织选择框数据")
    @GetMapping(value = "/getPartySelect")
    public CommonResult<List<UmsNcOrg>> getPartySelect() {
        return CommonResult.success(umsNcOrgService.getPartySelect());
    }
}
